fix: handle verified organization identity collisions#4060
Conversation
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
1 similar comment
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
464f826 to
05b339a
Compare
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Pull request overview
This PR improves the members enrichment worker’s organization upsert flow to recover from unique constraint collisions on verified organization identities, and to create organization merge suggestions when an enriched org’s verified identity is already owned by another organization.
Changes:
- Add collision recovery around
findOrCreateOrganizationfor the verified-identity unique index by retrying with the colliding identity demoted toverified: false. - When a collision occurs and the verified owner is found, create merge suggestions (raw + filtered) unless a no-merge record exists.
- Simplify org syncing by syncing the organization immediately after it is created/updated (instead of maintaining an accumulating
orgIdsToSynclist).
Comments suppressed due to low confidence (1)
services/apps/members_enrichment_worker/src/activities/enrichment.ts:530
orgPromisesare awaited viaPromise.all(...)while each promise can open a nestedqx.tx(...)(pg-promise SAVEPOINT). Running multiple nested transactions concurrently on the same underlying connection can interleave SAVEPOINT begin/release statements and break savepoint nesting, leaving the outer member update transaction in a failed/aborted state. Consider processing these org upserts sequentially (or otherwise ensure only oneqx.txruns at a time) when using savepoints for error recovery.
)
}
await Promise.all(orgPromises)
// ignore all organizations that were not created
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
Summary
Note
Medium Risk
Touches organization creation/identity handling inside the member enrichment transaction and introduces merge-suggestion side effects; mistakes could create incorrect org identities or noisy merge queues.
Overview
Member enrichment now recovers when creating an organization fails due to a verified organization-identity uniqueness collision.
On collision, it finds the existing organization that owns the verified identity, retries org creation without the colliding verified identities, re-adds those identities to the enriched org as unverified signals, and records high-similarity merge suggestions (skipping pairs marked as no-merge). Organization sync is also performed per created/updated org with structured logging instead of batching IDs.
Reviewed by Cursor Bugbot for commit a0c387c. Bugbot is set up for automated code reviews on this repo. Configure here.